package com.acme.bankapp.domain.bank;

public class CheckingAccount extends AbstractAccount {

	private double overdraft;

	public CheckingAccount(double balance, double overdraft) {
		this.balance = balance;
		this.overdraft = overdraft;
	}

	public boolean withdraw(double x) {

		if (this.balance >= x) {
			this.balance -= x;
			return true;
		}
		else {
			if (this.balance + this.overdraft > x) {
				this.overdraft += this.balance - x;
				this.balance = 0.0;
				return true;
			}
		}
		
		return false;
	}
	
	public double maximumAmountToWithdraw() {

		return this.balance + this.overdraft;
	}



}